package yxy.apple.util.concurrent;

import java.util.concurrent.*;

/**  */
public final class ScheduledFutureWrapper implements ScheduledFuture<Object> {
	private final ScheduledFuture<?> future;

	public ScheduledFutureWrapper(ScheduledFuture<?> future) {
		this.future = future;
	}

	@Override
	public long getDelay(TimeUnit unit) {
		return future.getDelay(unit);
	}

	@Override
	public int compareTo(Delayed o) {
		return future.compareTo(o);
	}

	/** 仅为了避免错误而使用Future.cancel(true) */
	@Override
	public boolean cancel(boolean mayInterruptIfRunning) {
		return future.cancel(false);
	}

	@Override
	public Object get() throws InterruptedException, ExecutionException {
		return future.get();
	}

	@Override
	public Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
		return future.get(timeout, unit);
	}

	@Override
	public boolean isCancelled() {
		return future.isCancelled();
	}

	@Override
	public boolean isDone() {
		return future.isDone();
	}
}
